<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增客户')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-clients-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">姓名：</label>
                    <div class="col-sm-8">
                        <input name="name" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">手机号：</label>
                    <div class="col-sm-8">
                        <input name="phone" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">地址：</label>
                    <div class="col-sm-8">
                        <input name="address" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/clients"
        $("#form-clients-add").validate({
            focusCleanup: true
        });


        function submitHandler() {
            // if ($.validate.form()) {
            //     $.operate.save(prefix + "/add", $('#form-clients-add').serialize());
            // }
            // console.log($('#form-clients-add'))
            $.operate.save(prefix + "/add", $('#form-clients-add').serialize(), {
                success: function (result) {
                    // 请求成功的处理逻辑
                    if (result.code === 200) {
                        alert("新增成功");
                    } else {
                        alert("新增失败：" + result.msg);

                    }
                },
                error: function () {
                    // 请求失败的处理逻辑，清空表单
                    alert("请求失败，请稍后重试");
                }
            });
        }
    </script>
</body>
</html>